<%--
  Created by IntelliJ IDEA.
  User: dell
  Date: 2024/8/15
  Time: 10:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="static/jquery-2.1.4.js"></script>
</head>
<body>
    <input type="button" value="doGet" onclick="ajaxGet()">
    <input type="button" value="doPost" onclick="ajaxPost()">
    <input type="button" value="ajax" onclick="ajax()">

    <script>
        function ajaxGet() {
            $.get(
                '/ajax1',
                {"name":"张三"},
                function (jsonObj) {
                    console.log(jsonObj)
                },
                'json'
            );
        }

        function ajaxPost() {
            $.post(
                '/ajax1',
                {"name":"张三2"},
                function (jsonObj) {
                    console.log(jsonObj)
                },
                'json'
            );
        }

        function ajax() {
            $.ajax({
                async:true,
                url: '/ajax1',
                type: 'POST',
                data: {"name":"张三3"},
                success: function (jsonObj) {
                    console.log(jsonObj);
                },
                dataType: 'json'
            });
        }
    </script>
</body>
</html>
